package com.enjoy.list;

import java.io.*;
import java.nio.file.Files;
import java.util.Arrays;

public class GenerateTest {
    public static void main(String[] args) throws IOException {
        long l = System.currentTimeMillis();
        int[] ages = new int[100];
        final String fileName = "f:\\age.txt";
        File file = new File(fileName);
        BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(file.toPath())));
        String str;
        while ((str = reader.readLine()) != null) {
            int i = Integer.parseInt(str);
            ages[i] = ages[i] + 1;
        }

        System.out.println(Arrays.toString(ages));

        for (int i = 0; i < ages.length; i++) {
            System.out.println("年龄:" + i + "," + "人数:" + ages[i]);
        }

        System.out.println("消耗时间:" + (System.currentTimeMillis() - l) / 1000);
    }
}
